package ywpt.service.people;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.stereotype.Service;

import ywpt.core.dao.HibernateEntityDao;
import ywpt.model.PeopleEducation;
import ywpt.model.PeopleInfo;
@Service("educationService")
public class EducationServiceImpl extends HibernateEntityDao<PeopleEducation> implements EducationService {

	public EducationServiceImpl(){
		
	}

	@Override
	public PeopleEducation getEducationInfoById(Long id) {
		return this.get(id);
	}

	@Override
	public int getEducationInfoCountByCriteria(DetachedCriteria query) {
		return this.getCountByCriteria(query);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<PeopleEducation> getEducationInfos(DetachedCriteria query) {
		return this.findAllByCriteria(query);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<PeopleEducation> getEducationInfos(DetachedCriteria query,
			int pageSize, int startIndex) {
		return this.findAllByCriteria(query, pageSize, startIndex);
	}

	@Override
	public void removeEducationInfo(Long id) {
		this.removeById(id);
	}

	@Override
	public void saveEducationInfo(PeopleEducation educationInfo,Long peopleId) {
		if(peopleId != null){
			educationInfo.setPeople(this.get(PeopleInfo.class, peopleId));
		}
		super.save(educationInfo);
	}

	@Override
	public void updateEducationInfo(PeopleEducation educationInfo,Long peopleId) {
		if(peopleId != null){
			educationInfo.setPeople(this.get(PeopleInfo.class, peopleId));
		}
		super.update(educationInfo);
	}

	
	
	
}
